<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <title>网咖充值</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>
    <link href="{{url('css/main.css')}}" type="text/css" rel="stylesheet"/>
    <script src="{{url('js/jquery.js')}}" type="text/javascript"></script>
</head>

<body>
<div class="transfer_box_top">

</div>
<div style=" width:100%; height:8px; background-color:#efefef;  border-top:solid 1px #e3e3e5; border-bottom:solid 1px #e3e3e5;"></div>

<p class="sel_title">请选择充值网咖：</p>

<div style="padding-left:10px; padding-right:10px; padding-bottom:10px;">
    <select class="sel_bar" name="bar">
        @foreach($bars as $bar)
            <option value="{{$bar->sid}}">{{$bar->sname}}</option>
        @endforeach
    </select>
</div>
</div>
</div>

<p class="sel_title">请输入充值金额：</p>

<div style="padding-left:10px; padding-right:10px; padding-bottom:10px;">
    <div class="box_input_money">
        <div class="box_img_money"><img src="{{url('images/transfer_ico_input.png')}}" width="40"></div>
        <input class="input_money" type="number" name="gold">
    </div>
</div>


<div style="padding:10px;"><input class="input_complete" type="button" value="确认充值"  id="pays"></div>
{{--<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>--}}
<script type="text/javascript" charset="utf-8">
    {{--wx.config(<?php echo $js->config(array('onMenuShareQQ', 'onMenuShareWeibo','chooseWXPay'), true, true) ?>);
    wx.ready(function () {
        });--}}
    document.querySelector('#pays').onclick = function () {
        //alert(5);
        var total_fee=$('.sel_bar').val();
        alert(total_fee);
        var bar=$('.input_money').val();
        alert(bar);
        $.post("/wx/dorecharge",{total_fee:total_fee,bar:bar},function(result){
            alert(result);
            if( typeof WeixinJSBridge === 'undefined' ) {
                alert('请在微信在打开页面！');
                return false;
            }
            WeixinJSBridge.invoke(
                    'getBrandWCPayRequest',result, function(res) {
                        switch(res.err_msg) {
                            case 'get_brand_wcpay_request:cancel':
                                alert('用户取消支付！');
                                break;
                            case 'get_brand_wcpay_request:fail':
                                alert('支付失败！（'+res.err_desc+'）');
                                break;
                            case 'get_brand_wcpay_request:ok':
                                alert('支付成功！');
                                break;
                            default:
                                alert(JSON.stringify(res));
                                break;
                        }
                    });
        });
        //WXPayment();
    };

    var WXPayment = function() {

    }
</script>
</body>

</html>
